function sectionChargeObj(tbodyID,data){
	this.tbodyObj = document.getElementById(tbodyID);
	this.count = 0;
	this.data = data;
	//this.data = "0,请选择;1,9002-刷卡;3,9001-积分;"
	this.initTbody = function(){
		this.addButton();
		this.addSection();
	};
	this.addSection = function(){
		var td1 = new newTD1().buildTD();
		var td2 = new newTD2(this).buildTD();
		var td3 = new newTD3().buildTD();
		var td4 = new newTD4(this.tbodyObj,this).buildTD();
		var tr1 = new newTR1(td1,td2,td3,td4).buildTR();
		this.tbodyObj.appendChild(tr1);
		//document.writeln(this.tbodyObj.innerHTML);
	};
	this.deleteSection = function(){
		var trs = this.tbodyObj.getElementsByTagName("TR");
		var   len   =   trs.length;
		if(len>5)
          this.tbodyObj.removeChild(trs[len-2]);

	};
	this.addButton= function(){
		var td1 = new newTDWithTable(this).buildTD();
		var tr1 = new newHeadTR(td1).buildTR();
		this.tbodyObj.appendChild(tr1);
	};
	this.getResult=function(){
		var str = "0,";
		var inputObj = this.tbodyObj.getElementsByTagName('INPUT');
		if(inputObj.length == 1){
			str = inputObj[0].value;
		}else
		{
			for(var i = 0 ; i < inputObj.length; i++)
			{
				if(i == 0)
				   str= str+inputObj[i].value+","+inputObj[i+1].value+";";
				if(i>1 && i % 2 == 0 && i < inputObj.length-1)
				   str = str+inputObj[i-2].value+","+inputObj[i].value+","+inputObj[i+1].value+";";
				if(i == inputObj.length-1)
				   str = str+inputObj[i-2].value+",99999,"+inputObj[i].value+";";
			}

		}
		return str;
	}
}
function newTD1(){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_td1";
		mytd.innerHTML="支付金额：";
		return mytd;
	}
}
function newTD2(sectionChargeObj){
	this._sectionChargeObj = sectionChargeObj;
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_require";
		myinput = document.createElement('input');
		var count = this._sectionChargeObj.count++;
		myinput.type="text";myinput.name="name"+count;myinput.className="required float-range-0-99999";myinput.size="16";myinput.align="right";myinput.setAttribute("afterInsert","tip"+count);
		myinputtext = document.createTextNode("元");
		myspan = document.createElement('span');
		myspan.id = "tip"+count;
		mytd.appendChild(myinput);
		mytd.appendChild(myinputtext);
		mytd.appendChild(myspan);
		return mytd;
	}
}
function newTD3(){
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_td1";
		mytd.innerHTML="支付方式";
		return mytd;
	}
}
function newTD4(tbodyObj,sectionChargeObj){
	this._tbodyObj = tbodyObj;
	this._sectionChargeObj = sectionChargeObj;
	this.buildTD= function (){
		var mytd = document.createElement('td');
		mytd.className="aux_intable_require";
		var count = this._sectionChargeObj.count++;
		var myselect = document.createElement('select');
		myselect.name="select"+count;
		myselect.style.width ="110px";
		var optionText = new Array();
		var optionValue = new Array();
		var objArray = this._sectionChargeObj.data.split(";");
		if(objArray.length >0)
		{
			for(var i = 0 ; i < objArray.length; i++)
			{
				var objs = objArray[i].split(",");
				optionText[i] = objs[1];
				optionValue[i] = objs[0];
				myselect.options[i] = new Option(optionText[i], optionValue[i]);
			}
		}
		mytd.appendChild(myselect);
		return mytd;
	}
}
function newTR1(tdObject1,tdObject2,tdObject3,tdObject4){
	this.tdObject1 = tdObject1;
	this.tdObject2 = tdObject2;
	this.tdObject3 = tdObject3;
	this.tdObject4 = tdObject4;
	this.buildTR = function(){
		var mytr = document.createElement('tr');
		mytr.appendChild(this.tdObject1);
		mytr.appendChild(this.tdObject2);
		mytr.appendChild(this.tdObject3);
		mytr.appendChild(this.tdObject4);
		return mytr;
	}
}
function newTable1(sectionChargeObj)
{
	this._sectionChargeObj = sectionChargeObj;
	this.buildTABLE = function(){
		var mytable = document.createElement('table');
		mytable.border="0";
		mytable.cellPadding="0";
		mytable.cellSpacing="0";
		mytable.setAttribute("_sectionCharge", this._sectionChargeObj);
		mytable.onclick = function(){
			this._sectionCharge.addSection();

		};
		var tr = mytable.insertRow();
		var td0 = tr.insertCell(0);
		td0.className ='buttonOffLeft';
		td0.id = "btn1_71";
		var td1 = tr.insertCell(1);
		td1.className = "buttonOffMiddle";
		td1.id="btn1_72";
		td1.onMouseOver="btn_change_over(7)";
		td1.onMouseOut="btn_change_out(7)";
		td1.onblur="btn_change(7)";
		td1.innerHTML = "<img src='images/ico_zengjia.gif' border='0' align='absbottom'/>增加支付方式";
		var td2 = tr.insertCell(2);
		td2.className = "buttonOffRight";
		td2.id="btn1_73";
		return mytable;
	}
}
function newTable2(sectionChargeObj)
{
	this._sectionChargeObj = sectionChargeObj;
	this.buildTABLE = function(){
		var mytable = document.createElement('table');
		mytable.border="0";
		mytable.cellPadding="0";
		mytable.cellSpacing="0";
		mytable.setAttribute("_sectionCharge", this._sectionChargeObj);
		mytable.onclick = function(){
			this._sectionCharge.deleteSection();
		};
		var tr = mytable.insertRow();
		var td0 = tr.insertCell(0); td0.className ='buttonOffLeft'; td0.id = "btn1_81";
		var td1 = tr.insertCell(1); td1.className = "buttonOffMiddle";td1.id ="btn1_82";td1.onMouseOver="btn_change_over(8)"; td1.onMouseOut="btn_change_out(8)"; td1.onblur="btn_change(8)";
		td1.innerHTML = "<img src='images/ico_cancel.gif' border='0' align='absbottom'/>删除支付方式 "
		var td2 = tr.insertCell(2); td2.className = "buttonOffRight";td2.id="btn1_83";
		return mytable;
	}
}
function newTDWithTable(sectionChargeObj)
{
	this._sectionChargeObj = sectionChargeObj;
	this.buildTD = function(){
		var mytd = document.createElement('td');
		mytd.className="aux_titletable";
		mytd.colSpan="4";
		var mytable = document.createElement('table');
		mytable.border="0";
		mytable.cellPadding="0";
		mytable.cellSpacing="0";
		var mytr1 = mytable.insertRow();
		var mytd1= mytr1.insertCell(0);
		mytd1.innerHTML="<strong >支付方式 </strong>";
		var mytd2= mytr1.insertCell(1);
		mytd2.innerHTML="&nbsp;";
		var mytd3= mytr1.insertCell(2);
		mytd3.appendChild(new newTable1(this._sectionChargeObj).buildTABLE());
		var mytd4 = mytr1.insertCell(3);
		mytd4.width="4%";
		mytd4.innerHTML="&nbsp;";
		var mytd5 = mytr1.insertCell(4);
		mytd5.appendChild(new newTable2(this._sectionChargeObj).buildTABLE());
		mytd.appendChild(mytable);
		return mytd;
	}
}
function newHeadTR(tdObject1){
	this.tdObject1 = tdObject1;
	this.buildTR = function(){
		var mytr = document.createElement('tr');
		mytr.appendChild(this.tdObject1);
		return mytr;
	}
}